import { service as axios } from './axios'
import qs from "qs"

function get(url: string, config?: object) {
  return new Promise((resolve, reject) => {
    axios
      .get(url, config)
      .then(res => {
        resolve({ data: res.data, err: null })
      })
      .catch(err => {
        resolve({data: null, err})
      })
  })
}
function post(url: string, params?: object, config?: object) {
  return new Promise((resolve, reject) => {
    axios
      .post(url, qs.stringify(params), config)
      .then(res => {
        resolve({ data: res.data, err: null })
      })
      .catch(err => {
        resolve({data: null, err})
      })
  })
}


export const http = {
  get,
  post
}
